<template>
	<view class="u-m-b-100 u-p-b-130">
		<view class="u-m-30 combox">
			<view class="u-flex u-p-b-20" style="overflow-x: auto;column-gap: 15px;">
				<view class="b-r-10 " :class="showIndex == index?'borderFen':'u-border' " v-for="(item,index)  in  listData" :key="index" @click="handleshow(item,index)">
					<view>
						<image :src="item.goodsImage" mode="" class="u-wd-120 u-he-80" style="border-radius: 10px 10px 0 0;"></image>
					</view>
					<view class="u-p-l-10 u-m-b-20 u-m-t-20 u-line-1 u-font-12" :class="showIndex == index?'Fen':'' ">
						{{item.goodsName}}
					</view>
					<view class=" text-center u-font-15 f-w" :class="showIndex == index?'Fen':'' ">
						¥&nbsp;{{item.sellPrice}}
					</view>
					<view class=" text-center u-font-12 u-p-b-20" :class="showIndex == index?'Fen':'' ">
						官方价：<text style="text-decoration: line-through;">¥{{item.marketPrice}}</text> 
					</view>
				</view> 
			</view>
			<view class="u-flex u-flex-between u-flex-y-center">
				<view class="u-font-14 c-000">
					购买数量
				</view>
				<view class="u-m-t-20 u-flex u-flex-y-center">
					<!-- <u-number-box v-model="value" class="u-flex"> -->
						<view slot="minus" class="minus">
							<u-icon name="minus" size="12"></u-icon>
						</view>
						<text slot="input" style="width: 20px;text-align: center;" class="input u-font-14">1</text>
						<view slot="plus" class="plus">
							<u-icon name="plus" size="12"></u-icon>
						</view>
					<!-- </u-number-box> -->
				</view>
			</view>
			<view class="u-border-top u-flex u-flex-between u-m-t-20 u-p-t-30 c-333" style="color:#ff6767">
				单次限购一张，可多次购买，非质量问题或超时无法退换
			</view>
		</view>
		<view class="combox u-m-30">
			<view class="u-font-14 f-w">
				充值账号
			</view>
			<view class="u-font-30 u-m-30 c-999">
				 <u--input 
				    placeholder="请输入账号"
				    border="bottom "
				    v-model="account"
				    @change="change"
				  ></u--input>
			</view>
			<view class="u-border-top u-flex u-flex-between u-m-t-20 u-p-t-30 c-333" style="color:#ff6767">
				购买须知:请仔细核对充值卡号，确保卡号准确性。虚拟商品不支持退货
			</view>
		</view>
		<view class="combox u-m-30">
			<view class="u-font-14 f-w">
				购买须知
			</view>
			<view class="u-font-30 u-m-30 c-999">
				1.官方直充，提交<text style="background-color: #ff6767;color: #fff;padding:0 10px">{{attachTips}}，</text> 充值秒到。<br/>
				2.本商品和官方充值权益相同，具体会员功能可查看官方app<br/>
				3.质保当天，如有质量问题，请于购买后24小时内联系客服处理，非质量问题不可退/换货，谢谢!
			</view>
		</view>
		<view class="footbuy u-he-60 u-border-top u-flex u-flex-y-center u-flex-between u-p-l-30 u-p-r-30">
			<view class="u-flex u-flex-y-center">
				<view class="text-center u-m-r-30">
					<image src="../../static/images/home.png" mode="" class="u-wd-25 u-he-25 "></image>
					<view class="u-font-24">首页</view>
				</view>
				<!-- <view class="text-center u-m-r-30">
					<image src="../../static/images/collect.png" mode="" class="u-wd-25 u-he-25 "></image>
					<view class="u-font-24">收藏</view>
				</view> -->
				
				
			</view>
			<view class="u-flex u-flex-y-center"> 
				<view class="text-center u-m-r-30 u-font-16 Fen">
					价格：{{itemInfo.sellPrice}}
				</view>
				<view class="bg-gradual-orange b-r-20 u-wd-100 u-he-35 text-center u-lihe-35" @click="handleplaceOrder()">
					立即购买
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				showIndex:0,
				banList: [
					'https://cdn.uviewui.com/uview/swiper/swiper1.png',
					'https://cdn.uviewui.com/uview/swiper/swiper2.png',
					'https://cdn.uviewui.com/uview/swiper/swiper3.png',
				],
				account:'',
				groupId: "",
				info: {},
				shopDataList: [],
				packageContent: [],
				listData:[],
				attachTips:"",
				itemInfo:""
			}
		},
		onLoad(opt) {
			this.groupId = opt.groupId
			this.getGoodInfo()
		},
		methods: {
			
			handleplaceOrder(){
				if(!this.account){
					uni.showToast({
						title:'请填写手机号',
						icon: 'none'
					});
					return
				}
				let data = {
					orderType:1,
					goodsId:this.itemInfo.goodsId,
					totalMoney:this.itemInfo.sellPrice,
					totalNum:1,
					account:this.account,
				}
				this.$api.placeOrderApi(data).then(res=>{
					this.account = ''
					uni.showToast({
						title:'购买成功',
						icon: 'none'
					});
					setTimeout(()=>{
						uni.$u.route('pages/order/order');
					},1000)
				})
			},
			handleshow(item,index){
				this.showIndex = index
				this.itemInfo = item;
			},
			getGoodInfo() {
				let data = {
					 groupId:this.groupId
				}
				this.$api.getCardGoodsListApi(data).then(res => {
					this.listData = res.data
					this.itemInfo = this.listData[0]
					let attachTips = JSON.parse(res.data[0].attach) 
					this.attachTips = attachTips[0].tip
					console.log(this.attachTips)
				})
			},
			onPhone(goods) {
				uni.makePhoneCall({
					phoneNumber: goods.contactsTel
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.borderFen{
		border: 1px solid #ff6767;
	}
	.Fen{
		color:#ff6767 ;
	}
	.footbuy {
		position: fixed;
		bottom: 0;
		width: 100%;
		background-color: #fff;
	}

	.minus {
		width: 22px;
		height: 22px;
		background-color: #e7e7e7;
		border-radius: 10rpx;
		@include flex;
		justify-content: center;
		align-items: center;
	}

	.input {
		padding: 0 10px;
	}

	.plus {
		width: 22px;
		height: 22px;
		background-color: #e7e7e7;
		border-radius: 10rpx;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: center;
		align-items: center;
	}

	.good-list {
		.good-li {
			display: flex;
			align-items: center;
			padding: 20upx;
			padding-bottom: 0;

			.good-img {
				width: 160upx;
				height: 160upx;
				margin-right: 20rpx;

			}

			.flex-item {
				flex: 1;



				.good-price {
					font-size: 26upx;
					color: red;
				}

				.good-sold {
					font-size: 24upx;
					color: gray;
					text-decoration: line-through;
				}

			}
		}
	}
</style>